import java.util.Arrays;

public class SelectSort {
    public static void main(String[] args) {
        int[] elem = {16,3,2,5,13,45,6,4,2,45};
        selectSort(elem);
        System.out.println(Arrays.toString(elem));
    }
    public static void selectSort(int[] array){
        for (int i = 0; i < array.length; i++) {
            int minindex = i;
            for (int j = i+1; j < array.length; j++) {
                if(array[j] < array[minindex]){
                    minindex = j;
                }
            }
            swap(array,i,minindex);
        }
    }
    public static void swap(int[] array,int i,int j){
        int tmp = array[i];
        array[i] = array[j];
        array[j] = tmp;
    }
}
